<template>
    <div>
        <h1>医生显示页面</h1>
        <a href="/Show">返回首页</a> &nbsp;&nbsp;&nbsp;
        <a href="/DecliceAdd">新增医生</a> &nbsp;&nbsp;&nbsp;
            <table class="table">
                    <thead>
                        <tr>    
                            <td>编号</td>
                            <td>姓名</td>
                            <td>头像</td>
                            <td>科室</td>
                            <td>创建日期</td>
                            <td>操作</td>
                        </tr>
                    </thead>
                    <tbody>
                        <tr v-for="a in data">    
                            <td>{{a.did}}</td>
                            <td>{{a.dName}}</td>
                            <td>
                                <img :src="'https://localhost:7036/'+a.dimg" style="width: 60px; height: 60px;">
                            </td>
                            <td>{{a.keName}}</td>
                            <td>{{a.yTimes.substring(0,10)}}</td>
                            <td>操作</td>
                        </tr>
                    </tbody>
            </table>
                当前第{{page.index}}页,共{{index.num}}页,共{{index.count}}行,每页{{page.size}}条
            <input type="button" value="首页" @click="fanye(1)">
            <input type="button" value="上一页" @click="fanye(2)">
            <span v-for="a in index.num">
                <input type="button" :value="a" @click="fen(a)">
            </span>
            <input type="button" value="下一页" @click="fanye(3)">
            <input type="button" value="尾页" @click="fanye(4)">

            <select v-model="page.size" @click="fanfan">
                <option value="1">1</option>
                <option value="2">2</option>
                <option value="3">3</option>
                <option value="4">4</option>
                <option value="5">5</option>
            </select>

            <input type="test" v-model="page.index" ><input type="button" value="跳转" @click="Show">
    </div>
</template>

<script setup lang="ts">
import {onMounted, ref} from 'vue'
import axios from 'axios'
import { useRouter } from 'vue-router'
const router = useRouter();

const fanfan=()=>{
    page.value.index=1;
    Show()
}


///分页
const fanye=(a:any)=>{
            if(a==1)
        {
            page.value.index=1;
        }
                if(a==2)
        {
                if(page.value.index>1)
                {
                        page.value.index-=1;
                }
        }
                if(a==3)
        {
                if(page.value.index<index.value.num)
                {
                        page.value.index+=1;
                }
        }
                if(a==4)
        {
                    page.value.index=index.value.num;
        }
        Show()
}


const fen=(b:any)=>{
    page.value.index=b;
    Show();
}




onMounted(()=>{
    Show()
})

const data = ref([
    {
             "did": 6,
      "dName": "李四",
      "dimg": "/img/73ad8761-96be-414b-8b3e-05bd78b7342e1.png",
      "kid": 4,
      "yTimes": "2025-05-19T12:55:38.1978666",
      "keName": "一类科室"
    }
])

var page = ref({
    index:1,
    size:3
})

var index = ref({
    count:0,
    num:0
})

const Show=()=>{
    axios.get("/api/Declice/ShowDeclice",{params:page.value}).then(res=>{
        data.value=res.data.list;
index.value.count = res.data.num;
index.value.num = Math.ceil(index.value.count/page.value.size);
    })
}

</script>

<style scoped>

</style>